/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pl.edu.agh.administracja.networkconfig;

import javax.swing.JList;
import javax.swing.JOptionPane;
import pl.edu.agh.administracja.networkconfig.model.util.ShellExecutor;
import pl.edu.agh.administracja.networkconfig.model.util.ShellTaskCallback;

/**
 *
 * @author radek
 */
public class MainFrame extends javax.swing.JFrame {

    /**
     * Creates new form MainFrame
     */
    public MainFrame() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        interfaceConfigFrame = new javax.swing.JFrame();
        headerInterfaceConfig = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        dhcpCheckbox = new javax.swing.JCheckBox();
        emptyPanel = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        ipTextInput = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        maskTextInput = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        gateTextInput = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        sentTextInput = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        receivedTextInput = new javax.swing.JTextField();
        jPanel4 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jPanel10 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jPanel7 = new javax.swing.JPanel();
        wirelessName = new javax.swing.JLabel();
        wirelessNameTextField = new javax.swing.JTextField();
        wirelessSignalStrength = new javax.swing.JLabel();
        wirelessSignalStrengthTextField = new javax.swing.JTextField();
        jPanel3 = new javax.swing.JPanel();
        jButton4 = new javax.swing.JButton();
        loadInterfaceConfigFrame = new javax.swing.JFrame();
        jScrollPane2 = new javax.swing.JScrollPane();
        jList2 = new javax.swing.JList();
        jPanel5 = new javax.swing.JPanel();
        okLoadInterfaceConfigButton = new javax.swing.JButton();
        cancelLoadInterfaceConfigButton = new javax.swing.JButton();
        loadOverallConfigFrame = new javax.swing.JFrame();
        jScrollPane3 = new javax.swing.JScrollPane();
        jList3 = new javax.swing.JList();
        jPanel6 = new javax.swing.JPanel();
        okLoadInterfaceConfigButton1 = new javax.swing.JButton();
        cancelLoadInterfaceConfigButton1 = new javax.swing.JButton();
        loadWirelessNetworkConfigFrame = new javax.swing.JFrame();
        jScrollPane4 = new javax.swing.JScrollPane();
        jList4 = new javax.swing.JList();
        jPanel11 = new javax.swing.JPanel();
        okLoadWirelessNetworkConfigButton = new javax.swing.JButton();
        cancelLoadWirelessNetworkConfigButton = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jList1 = new javax.swing.JList();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();

        interfaceConfigFrame.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        interfaceConfigFrame.getContentPane().setLayout(new javax.swing.BoxLayout(interfaceConfigFrame.getContentPane(), javax.swing.BoxLayout.Y_AXIS));

        headerInterfaceConfig.setFont(new java.awt.Font("Dialog", 1, 24)); // NOI18N
        headerInterfaceConfig.setText("jLabel1");
        interfaceConfigFrame.getContentPane().add(headerInterfaceConfig);

        jPanel1.setLayout(new java.awt.GridLayout(6, 2));

        dhcpCheckbox.setText("DHCP");
        jPanel1.add(dhcpCheckbox);
        jPanel1.add(emptyPanel);

        jLabel2.setText("IP");
        jPanel1.add(jLabel2);

        ipTextInput.setEditable(false);
        ipTextInput.setText("192.168.0.1");
        jPanel1.add(ipTextInput);

        jLabel3.setText("Maska");
        jPanel1.add(jLabel3);

        maskTextInput.setEditable(false);
        maskTextInput.setText("255.255.255.255");
        maskTextInput.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                maskTextInputActionPerformed(evt);
            }
        });
        jPanel1.add(maskTextInput);

        jLabel4.setText("Brama");
        jPanel1.add(jLabel4);

        gateTextInput.setEditable(false);
        gateTextInput.setText("192.168.0.1");
        jPanel1.add(gateTextInput);

        jLabel5.setText("Wysłano");
        jPanel1.add(jLabel5);

        sentTextInput.setEditable(false);
        sentTextInput.setText("60kB");
        jPanel1.add(sentTextInput);

        jLabel6.setText("Odebrano");
        jPanel1.add(jLabel6);

        receivedTextInput.setEditable(false);
        receivedTextInput.setText("40B");
        jPanel1.add(receivedTextInput);

        interfaceConfigFrame.getContentPane().add(jPanel1);

        jPanel4.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));

        jButton1.setText("Zmień");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        jPanel4.add(jButton1);

        jButton2.setText("Zapisz");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        jPanel4.add(jButton2);

        jButton3.setText("Wczytaj");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });
        jPanel4.add(jButton3);

        interfaceConfigFrame.getContentPane().add(jPanel4);

        jPanel10.setLayout(new javax.swing.BoxLayout(jPanel10, javax.swing.BoxLayout.Y_AXIS));

        jPanel2.setLayout(new javax.swing.BoxLayout(jPanel2, javax.swing.BoxLayout.Y_AXIS));
        jPanel10.add(jPanel2);

        jLabel1.setFont(new java.awt.Font("Dialog", 1, 24)); // NOI18N
        jLabel1.setText("Siec bezprzewodowa");
        jPanel10.add(jLabel1);

        jPanel7.setLayout(new java.awt.GridLayout(2, 2));

        wirelessName.setText("nazwa");
        jPanel7.add(wirelessName);

        wirelessNameTextField.setEditable(false);
        wirelessNameTextField.setText("siec AGH");
        wirelessNameTextField.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jPanel7.add(wirelessNameTextField);

        wirelessSignalStrength.setText("siła sygnału");
        jPanel7.add(wirelessSignalStrength);

        wirelessSignalStrengthTextField.setEditable(false);
        wirelessSignalStrengthTextField.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        wirelessSignalStrengthTextField.setText("bardzo dobra");
        wirelessSignalStrengthTextField.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jPanel7.add(wirelessSignalStrengthTextField);

        jPanel10.add(jPanel7);

        jPanel3.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));

        jButton4.setText("Zmien");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });
        jPanel3.add(jButton4);

        jPanel10.add(jPanel3);

        interfaceConfigFrame.getContentPane().add(jPanel10);

        loadInterfaceConfigFrame.getContentPane().setLayout(new javax.swing.BoxLayout(loadInterfaceConfigFrame.getContentPane(), javax.swing.BoxLayout.Y_AXIS));

        jList2.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Konfig 1", "Konfig 2" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jScrollPane2.setViewportView(jList2);

        loadInterfaceConfigFrame.getContentPane().add(jScrollPane2);

        okLoadInterfaceConfigButton.setText("Ok");
        okLoadInterfaceConfigButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                okLoadInterfaceConfigButtonActionPerformed(evt);
            }
        });
        jPanel5.add(okLoadInterfaceConfigButton);

        cancelLoadInterfaceConfigButton.setText("Anuluj");
        cancelLoadInterfaceConfigButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelLoadInterfaceConfigButtonActionPerformed(evt);
            }
        });
        jPanel5.add(cancelLoadInterfaceConfigButton);

        loadInterfaceConfigFrame.getContentPane().add(jPanel5);

        loadOverallConfigFrame.getContentPane().setLayout(new javax.swing.BoxLayout(loadOverallConfigFrame.getContentPane(), javax.swing.BoxLayout.Y_AXIS));

        jList3.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Konfig 1", "Konfig 2" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jScrollPane3.setViewportView(jList3);

        loadOverallConfigFrame.getContentPane().add(jScrollPane3);

        okLoadInterfaceConfigButton1.setText("Ok");
        okLoadInterfaceConfigButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                okLoadInterfaceConfigButton1ActionPerformed(evt);
            }
        });
        jPanel6.add(okLoadInterfaceConfigButton1);

        cancelLoadInterfaceConfigButton1.setText("Anuluj");
        cancelLoadInterfaceConfigButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelLoadInterfaceConfigButton1ActionPerformed(evt);
            }
        });
        jPanel6.add(cancelLoadInterfaceConfigButton1);

        loadOverallConfigFrame.getContentPane().add(jPanel6);

        loadWirelessNetworkConfigFrame.getContentPane().setLayout(new javax.swing.BoxLayout(loadWirelessNetworkConfigFrame.getContentPane(), javax.swing.BoxLayout.Y_AXIS));

        jList4.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "siec 1", "siec 2", "siec 3" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jScrollPane4.setViewportView(jList4);

        loadWirelessNetworkConfigFrame.getContentPane().add(jScrollPane4);

        okLoadWirelessNetworkConfigButton.setText("Ok");
        okLoadWirelessNetworkConfigButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                okLoadWirelessNetworkConfigButtonActionPerformed(evt);
            }
        });
        jPanel11.add(okLoadWirelessNetworkConfigButton);

        cancelLoadWirelessNetworkConfigButton.setText("Anuluj");
        cancelLoadWirelessNetworkConfigButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelLoadWirelessNetworkConfigButtonActionPerformed(evt);
            }
        });
        jPanel11.add(cancelLoadWirelessNetworkConfigButton);

        loadWirelessNetworkConfigFrame.getContentPane().add(jPanel11);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setPreferredSize(new java.awt.Dimension(640, 480));

        jList1.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Interfejs 1", "Interfejs 2", "Interfejs 3" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jList1.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jList1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jList1MouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jList1);

        getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);

        jMenu1.setText("Plik");

        jMenuItem1.setText("Wczytaj konfigurację");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem1);

        jMenuItem2.setText("Test");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem2);

        jMenuBar1.add(jMenu1);

        setJMenuBar(jMenuBar1);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jList1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jList1MouseClicked
        // TODO add your handling code here:
        JList source = (JList) evt.getSource();
        headerInterfaceConfig.setText(source.getSelectedValue().toString());
        interfaceConfigFrame.pack();
        interfaceConfigFrame.setVisible(true);
    }//GEN-LAST:event_jList1MouseClicked

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        ipTextInput.setEditable(true);                
        maskTextInput.setEditable(true);
        gateTextInput.setEditable(true);
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        JOptionPane.showMessageDialog(interfaceConfigFrame, "Zapisano konfigurację");
        
        ipTextInput.setEditable(false);                
        maskTextInput.setEditable(false);
        gateTextInput.setEditable(false);
    }//GEN-LAST:event_jButton2ActionPerformed

    private void okLoadInterfaceConfigButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okLoadInterfaceConfigButtonActionPerformed
        // TODO add your handling code here:
        loadInterfaceConfigFrame.dispose();
        JOptionPane.showMessageDialog(interfaceConfigFrame, "Wczytano konfigurację");
    }//GEN-LAST:event_okLoadInterfaceConfigButtonActionPerformed

    private void cancelLoadInterfaceConfigButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelLoadInterfaceConfigButtonActionPerformed
        // TODO add your handling code here:
        loadInterfaceConfigFrame.dispose();
    }//GEN-LAST:event_cancelLoadInterfaceConfigButtonActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        // TODO add your handling code here:
        loadInterfaceConfigFrame.pack();
        loadInterfaceConfigFrame.setVisible(true);
    }//GEN-LAST:event_jButton3ActionPerformed

    private void okLoadInterfaceConfigButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okLoadInterfaceConfigButton1ActionPerformed
        // TODO add your handling code here:
        loadOverallConfigFrame.dispose();
        JOptionPane.showMessageDialog(this, "Wczytano konfigurację");
    }//GEN-LAST:event_okLoadInterfaceConfigButton1ActionPerformed

    private void cancelLoadInterfaceConfigButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelLoadInterfaceConfigButton1ActionPerformed
        // TODO add your handling code here:
        loadOverallConfigFrame.dispose();
    }//GEN-LAST:event_cancelLoadInterfaceConfigButton1ActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        // TODO add your handling code here:
        loadOverallConfigFrame.pack();
        loadOverallConfigFrame.setVisible(true);
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void maskTextInputActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_maskTextInputActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_maskTextInputActionPerformed

    private void cancelLoadWirelessNetworkConfigButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelLoadWirelessNetworkConfigButtonActionPerformed
        // TODO add your handling code here:
        loadWirelessNetworkConfigFrame.dispose();
    }//GEN-LAST:event_cancelLoadWirelessNetworkConfigButtonActionPerformed

    private void okLoadWirelessNetworkConfigButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okLoadWirelessNetworkConfigButtonActionPerformed
        // TODO add your handling code here:
        loadWirelessNetworkConfigFrame.dispose();
    }//GEN-LAST:event_okLoadWirelessNetworkConfigButtonActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        // TODO add your handling code here:
        loadWirelessNetworkConfigFrame.pack();
        loadWirelessNetworkConfigFrame.setVisible(true);
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        ShellExecutor.executeAsynchronously("ls", new ShellTaskCallback() {

            @Override
            public void execute(String commandResult) {
                JOptionPane.showMessageDialog(MainFrame.this, commandResult);
            }
        });
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new MainFrame().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton cancelLoadInterfaceConfigButton;
    private javax.swing.JButton cancelLoadInterfaceConfigButton1;
    private javax.swing.JButton cancelLoadWirelessNetworkConfigButton;
    private javax.swing.JCheckBox dhcpCheckbox;
    private javax.swing.JPanel emptyPanel;
    private javax.swing.JTextField gateTextInput;
    private javax.swing.JLabel headerInterfaceConfig;
    private javax.swing.JFrame interfaceConfigFrame;
    private javax.swing.JTextField ipTextInput;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JList jList1;
    private javax.swing.JList jList2;
    private javax.swing.JList jList3;
    private javax.swing.JList jList4;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JFrame loadInterfaceConfigFrame;
    private javax.swing.JFrame loadOverallConfigFrame;
    private javax.swing.JFrame loadWirelessNetworkConfigFrame;
    private javax.swing.JTextField maskTextInput;
    private javax.swing.JButton okLoadInterfaceConfigButton;
    private javax.swing.JButton okLoadInterfaceConfigButton1;
    private javax.swing.JButton okLoadWirelessNetworkConfigButton;
    private javax.swing.JTextField receivedTextInput;
    private javax.swing.JTextField sentTextInput;
    private javax.swing.JLabel wirelessName;
    private javax.swing.JTextField wirelessNameTextField;
    private javax.swing.JLabel wirelessSignalStrength;
    private javax.swing.JTextField wirelessSignalStrengthTextField;
    // End of variables declaration//GEN-END:variables
}
